﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Common;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace LightingServer
{
    public static class LightingServerContext
    {
        public static readonly string UserKey = "{F9903CC9-DBDE-454E-B1C0-EED302B9F7BE}";
        public static readonly string StaticResourceKey = "{88AC7D86-5174-44B5-874E-DC9FCC079A7A}";
        public static readonly string LightingKey = "{BD4A7BEE-8934-412A-8786-B568E16A5683}";

        public static string ImageRoot { get; set; }
        public static string ImageUrl { get; set; }
        public static string TemplateRoot { get; set; }
        public static string ExportRoot { get; set; }
        public static string ExportUrl { get; set; }
        public static string Database { get; set; }
        public static string[] CacheUrl { get; set; }
        public static double Expiry { get; set; }

        public static DbConnection CreateConnection(string connectionStrings)
        {
            return new MySqlConnection(connectionStrings);
        }

        public static DbConnection CreateConnection()
        {
            return CreateConnection(_connectionStrings);
        }

        public static string CreateGuid()
        {
            return Guid.NewGuid().ToString().ToUpper();
        }

        public static void WriteLine(string message)
        {
            Console.WriteLine(message);


            //try
            //{
            //    string file = "E:\\Setup\\zcdb.log";
            //    FileInfo fileinfo = new FileInfo(file);
            //    using (Stream stream = fileinfo.Open(FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read))
            //    {
            //        StreamWriter writer = new StreamWriter(stream, Encoding.GetEncoding("gb2312"));
            //        writer.WriteLine(message);
            //        writer.Flush();
            //        writer.Close();
            //    }
            //}
            //catch
            //{

            //}
        }
    }
}
